#ifndef __BSP_TIMER_H
#define __BSP_TIMER_H

#include "gd32f30x_timer.h"
#include "gd32f30x_gpio.h"

// 系统时钟
#define APB2_CLK (120000000LU)
#define APB1_CLK (APB2_CLK / 2U)

#define TIMER1_CLK (APB1_CLK)
#define TIMER0_CLK (APB2_CLK)
#define TIMER7_CLK (APB2_CLK)

// 定时器配置时钟
#define MOTOR_PWM_FRE_HZ  16000U //SVPWM_FREQ

// 定时器配置时钟
// 16K发波频率,定时器周期3750
#define M0_TIMER_PCS (1U)
#define M0_TIMER_PERIOD (TIMER1_CLK / M0_TIMER_PCS / MOTOR_PWM_FRE_HZ) 

// 定时器配置时钟
#define M1_TIMER_PCS (1U)
#define M1_TIMER_PERIOD (TIMER0_CLK / M0_TIMER_PCS / MOTOR_PWM_FRE_HZ / 2U) 

// 定时器配置时钟
#define M2_TIMER_PCS (1U)
#define M2_TIMER_PERIOD (TIMER7_CLK / M0_TIMER_PCS / MOTOR_PWM_FRE_HZ / 2U) 

extern void bsp_timer_init(void);

#endif
